package lk.icta.core.entity;

import lk.icta.common.AppConstants;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author Supun Nimesh Karunathilaka
 * @author Duminda Dharmakeerthi
 */
@Entity
@Table(schema = "ELAND_RAIL")
@NamedQueries({
        @NamedQuery(
                name = "getGeologicalTypeById",
                query = "SELECT g FROM GeologicalType g WHERE g.id = :id"
        )
})
public class GeologicalType implements Serializable {
    /**
     * This is an auto generated unique row identifier
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    @Column(nullable = false)
    private String enTypeName;

    @Column(nullable = false)
    private String siTypeName;

    @Column(nullable = false)
    private String taTypeName;

    @Column(nullable = true)
    private String typeDescription;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getEnTypeName() {
        return enTypeName;
    }

    public void setEnTypeName(String enTypeName) {
        this.enTypeName = enTypeName;
    }

    public String getSiTypeName() {
        return siTypeName;
    }

    public void setSiTypeName(String siTypeName) {
        this.siTypeName = siTypeName;
    }

    public String getTaTypeName() {
        return taTypeName;
    }

    public void setTaTypeName(String taTypeName) {
        this.taTypeName = taTypeName;
    }

    public String getTypeDescription() {
        return typeDescription;
    }

    public void setTypeDescription(String typeDescription) {
        this.typeDescription = typeDescription;
    }

    public String getGeologicalTypeNameByLanguage(String language) {
        String geologicalTypeName = "";
        if (AppConstants.ENGLISH.equals(language)) {
            geologicalTypeName = getEnTypeName();
        } else if (AppConstants.SINHALA.equals(language)) {
            geologicalTypeName = getSiTypeName();
        } else if (AppConstants.TAMIL.equals(language)) {
            geologicalTypeName = getTaTypeName();
        }

        return geologicalTypeName;
    }
}
